import { GetParkCarList } from "@/api/index";
const parkRemark = {
  PARK_A: "A栋流动车位",
  PARK_B: "B栋流动车位",
  PARK_C: "C栋流动车位",
  PARK_D: "D栋流动车位",
};
export default {
  namespaced: true,
  state: {
    list: [],
    hasPosition: {},
  },
  mutations: {
    commitList(state, payload) {
      state.list = [];
      for (const key in parkRemark) {
        const _ele = parkRemark[key];
        for (let i = 0; i < payload.length; i++) {
          const _data = payload[i];
          if (_ele == _data.remarks) {
            // console.log("_data", _data);
            _data.text = _ele.slice(0, 2);
            _data.process =
              ((_data.num - _data.num_use_extend) / _data.num) * 100;
            console.log(_data);
            state.list.push(_data);
            break;
          }
        }
      }
      let max = state.list[0];
      for (let i = 0; i < state.list.length - 1; i++) {
        max = max.process < state.list[i + 1].process ? state.list[i + 1] : max;
      }
      state.hasPosition = max;
    },
  },
  actions: {
    GetParkCarList({ commit }, params) {
      // GetParkCarList(params)
      //   .then((res) => {
      //     // console.log("vuex", res);
      //     let _data = res.data;
      //     // resolve(res);
      //     commit("commitList", _data);
      //   })
      //   .catch((err) => {
      //     console.log(err);
      //     // reject(err);
      //   });
      let _data = [
        {
          created: "2020-07-13 10:26:29.31",
          is_auth: "0",
          is_upload: "0",
          name: "A栋固定车位",
          num: "100",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "59",
          remarks: "A栋固定车位",
          status: "0",
          uid: "a48f5c3a-5e3e-477f-84c4-5eeb63481492",
          updated: "2022-02-22 15:40:39.101",
        },
        {
          created: "2020-07-08 14:59:50.529",
          is_auth: "0",
          is_upload: "0",
          name: "A栋流动车位",
          num: "165",
          num_use: "25",
          num_use0: "0",
          num_use1: "0",
          num_use2: "7",
          num_use3: "18",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "165",
          remarks: "A栋流动车位",
          status: "0",
          uid: "41ae6b34-0a20-4f88-b3a9-97c95796b0e4",
          updated: "2022-02-22 15:40:39.085",
        },
        {
          created: "2020-07-13 10:26:37.889",
          is_auth: "0",
          is_upload: "0",
          name: "B栋固定车位",
          num: "134",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "82",
          remarks: "B栋固定车位",
          status: "0",
          uid: "b526d190-c8b8-4d5e-9650-e457821f1c0e",
          updated: "2022-02-22 15:40:39.105",
        },
        {
          created: "2020-07-08 16:14:22.407",
          is_auth: "0",
          is_upload: "0",
          name: "B栋流动车位",
          num: "13",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "13",
          remarks: "B栋流动车位",
          status: "0",
          uid: "1daff3dd-d47a-470f-875c-8272fffbec3a",
          updated: "2022-02-22 15:40:39.072",
        },
        {
          created: "2020-07-13 10:26:42.306",
          is_auth: "0",
          is_upload: "0",
          name: "C栋固定车位",
          num: "100",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "56",
          remarks: "C栋固定车位",
          status: "0",
          uid: "2538834a-0fb3-4e9d-84f6-a79e3dca7600",
          updated: "2022-02-22 15:40:39.08",
        },
        {
          created: "2020-07-13 10:23:45.613",
          is_auth: "0",
          is_upload: "0",
          name: "C栋流动车位",
          num: "28",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "26",
          remarks: "C栋流动车位",
          status: "0",
          uid: "d057d4b9-9242-44d8-9ad7-49c20f86d973",
          updated: "2022-02-22 15:40:39.11",
        },
        {
          created: "2020-07-13 10:26:46.116",
          is_auth: "0",
          is_upload: "0",
          name: "D栋固定车位",
          num: "100",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "47",
          remarks: "D栋固定车位",
          status: "0",
          uid: "4ff57281-339a-4318-9b88-a85e50518def",
          updated: "2022-02-22 15:40:39.09",
        },
        {
          created: "2020-07-13 10:24:44.249",
          is_auth: "0",
          is_upload: "0",
          name: "D栋流动车位",
          num: "73",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "61",
          remarks: "D栋流动车位",
          status: "0",
          uid: "42316eaf-a7a0-4503-a325-413a3e1fe679",
          updated: "2022-02-22 15:40:39.087",
        },
        {
          created: "2020-08-25 17:45:07.757",
          is_auth: "1",
          is_upload: "0",
          name: "国际投资大厦",
          num: "720",
          num_use: "519",
          num_use0: "6",
          num_use1: "0",
          num_use2: "271",
          num_use3: "241",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "0",
          remarks: "国际投资大厦",
          status: "0",
          uid: "ee9d6e72-f3c5-45b5-a757-a9c7729a06e0",
          updated: "2022-02-22 15:40:39.111",
        },
        {
          created: "2020-11-05 17:00:15.446",
          is_auth: "1",
          is_upload: "0",
          name: "无通行权限",
          num: "1",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "0",
          remarks: "",
          status: "0",
          uid: "8bac5f7e-d3c7-4aa9-a410-77aa0a1b89cc",
          updated: "2022-02-22 15:40:39.096",
        },
        {
          created: "2020-08-27 10:27:12.52",
          is_auth: "0",
          is_upload: "0",
          name: "金融+A栋固定车位",
          num: "300",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "0",
          remarks: "",
          status: "0",
          uid: "b66b88b7-beb3-4c88-95e1-edef17c0a063",
          updated: "2022-02-22 15:40:39.108",
        },
        {
          created: "2020-08-27 10:26:39.354",
          is_auth: "0",
          is_upload: "0",
          name: "金融+A栋流动车位",
          num: "365",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "0",
          remarks: "",
          status: "0",
          uid: "660db0b3-cbbc-4cfc-8a82-0c616da2a075",
          updated: "2022-02-22 15:40:39.093",
        },
        {
          created: "2020-08-20 18:29:14.652",
          is_auth: "0",
          is_upload: "0",
          name: "金融固定车位",
          num: "100",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "39",
          remarks: "金融固定车位",
          status: "0",
          uid: "0c8224ec-4f17-44ba-86df-5277489ba874",
          updated: "2022-02-22 15:40:39.068",
        },
        {
          created: "2020-08-25 17:45:40.899",
          is_auth: "1",
          is_upload: "0",
          name: "金融大厦",
          num: "245",
          num_use: "172",
          num_use0: "1",
          num_use1: "0",
          num_use2: "132",
          num_use3: "39",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "0",
          remarks: "金融大厦",
          status: "0",
          uid: "a7799ecb-5386-4946-be46-163e7a5683c6",
          updated: "2022-02-22 15:40:39.103",
        },
        {
          created: "2020-08-20 18:28:52.225",
          is_auth: "0",
          is_upload: "0",
          name: "金融流动车位",
          num: "165",
          num_use: "0",
          num_use0: "0",
          num_use1: "0",
          num_use2: "0",
          num_use3: "0",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "132",
          remarks: "金融流动车位",
          status: "0",
          uid: "2072a983-1f97-4488-8a89-a70a82c7d429",
          updated: "2022-02-22 15:40:39.075",
        },
        {
          created: "2020-09-03 15:49:24.759",
          is_auth: "1",
          is_upload: "0",
          name: "高新大厦地库",
          num: "83",
          num_use: "2",
          num_use0: "1",
          num_use1: "0",
          num_use2: "0",
          num_use3: "1",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "0",
          remarks: "",
          status: "0",
          uid: "8c26ecf8-34bc-4bab-a4fa-981e425e707c",
          updated: "2022-02-22 15:40:39.098",
        },
        {
          created: "2020-08-25 17:46:02.386",
          is_auth: "1",
          is_upload: "0",
          name: "高新大厦地面",
          num: "80",
          num_use: "70",
          num_use0: "0",
          num_use1: "0",
          num_use2: "69",
          num_use3: "1",
          num_use4: "0",
          num_use5: "0",
          num_use_extend: "0",
          remarks: "高新大厦",
          status: "0",
          uid: "3a074d47-b43e-4059-ba4d-411776f98bc5",
          updated: "2022-02-22 15:40:39.083",
        },
      ];
      commit("commitList", _data);
    },
  },
};
